//
//  NSMAssetsManager.h
//  NSMKit
//
//  Created by nsm on 2019/2/27.
//  Copyright © 2019 nani. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "NSMAsset.h"

#define _assetsManager      ([NSMAssetsManager sharedInstance])

NS_ASSUME_NONNULL_BEGIN

/// Asset授权的状态
typedef NS_ENUM(NSUInteger, NSMAssetAuthorizationStatus) {
    NSMAssetAuthorizationStatusNotDetermined,   /// 未确定
    NSMAssetAuthorizationStatusNotAuthorized,   /// 拒绝
    NSMAssetAuthorizationStatusAuthorized       /// 允许
};

/// Asset类型
typedef NS_OPTIONS(NSInteger, NSMAssetSourceType) {
    NSMAssetSourceTypePhoto   = 1 << 0,   /// 图片
    NSMAssetSourceTypeVideo   = 1 << 1,   /// 视频
    NSMAssetSourceTypeAudio   = 1 << 2,   /// 音频
    NSMAssetSourceTypeAll     = NSMAssetSourceTypePhoto | NSMAssetSourceTypeVideo | NSMAssetSourceTypeAudio
};

@interface NSMAssetsManager : NSObject

+ (instancetype)sharedInstance;

#pragma mark - PHPhotoLibrary
+ (NSMAssetAuthorizationStatus)authorizationStatus;
+ (void)requestAuthorization:(void(^)(NSMAssetAuthorizationStatus status))handler;


/** 获取所有相册,同步耗时操作 */
- (NSArray<NSMAssetsGroup *> *)fecthAssetGroupsWithSourceType:(NSMAssetSourceType)sourceType;

/** 获取PHAsset缩略图 */
- (PHImageRequestID)fecthThumbnailImageForAsset:(PHAsset *)asset
                                           size:(CGSize)size
                                       completion:(void(^)(UIImage *__nullable result, NSDictionary *__nullable info))completion;

@end

NS_ASSUME_NONNULL_END
